<?php
namespace Modules\Home\Controllers;

class ControllerBase extends \Phalcon\Mvc\Controller {
  use \Common\Cache\BackendCacheTrait;

  protected function initialize() {
    $this -> tag -> setTitle('幸福汇');
    $this -> tag -> setTitleSeparator(' - ');
  }

  protected function _checkLogin() {
    if(!$this -> session -> has('user')) {
      return $this -> response -> redirect('/login');
    }
  }

  protected function _returnScript($message, $url = null) {
    $this -> response -> setContentType('text/html', 'UTF-8') -> setContent('<script type="text/javascript">');

    $this -> response -> appendContent('alert("' . $message . '");');

    if(is_null($url)) {
      $this -> response -> appendContent('window.history.back();');
    } else {
      $this -> response -> appendContent('window.location.href="' . $url . '"');
    }
    $this -> response -> appendContent('</script>');

    return $this -> response;
  }
}
?>